package com.ruoyi.tsjData.service.impl;

import java.util.List;

import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ProcessPictureUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.tsjData.domain.result.DataTshjZhdResult;
import com.ruoyi.tsjData.mapper.DataTshjZhdResultMapper;
import com.ruoyi.tsjData.service.IDataTshjZhdResultService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 提升机-制动测试结果Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-11-07
 */
@Service
public class DataTshjZhdResultServiceImpl implements IDataTshjZhdResultService
{
    @Autowired(required = false)
    private DataTshjZhdResultMapper dataTshjZhdResultMapper;

    /**
     * 查询提升机-制动测试结果
     * 
     * @param zhdResultId 提升机-制动测试结果主键
     * @return 提升机-制动测试结果
     */
    @Override
    public DataTshjZhdResult selectDataTshjZhdResultByZhdResultId(Long zhdResultId)
    {
        return dataTshjZhdResultMapper.selectDataTshjZhdResultByZhdResultId(zhdResultId);
    }

    /**
     * 查询提升机-制动测试结果列表
     * 
     * @param dataTshjZhdResult 提升机-制动测试结果
     * @return 提升机-制动测试结果
     */
    @Override
    public List<DataTshjZhdResult> selectDataTshjZhdResultList(DataTshjZhdResult dataTshjZhdResult)
    {
        return dataTshjZhdResultMapper.selectDataTshjZhdResultList(dataTshjZhdResult);
    }

    /**
     * 任务id获取制动测试结果
     * @param dataTaskId
     * @return
     */
    @Override
    public List<DataTshjZhdResult> selectDataTshjZhdResultByDataTaskId(Long dataTaskId, Long dataResultId) {
        return dataTshjZhdResultMapper.selectDataTshjZhdResultByDataTaskId(dataTaskId, dataResultId);
    }

    /**
     * 新增提升机-制动测试结果
     * 
     * @param dataTshjZhdResult 提升机-制动测试结果
     * @return 结果
     */
    @Override
    public int insertDataTshjZhdResult(DataTshjZhdResult dataTshjZhdResult)
    {
        dataTshjZhdResult.setCreateTime(DateUtils.getNowDate());
        String rootPath = RuoYiConfig.getProfile() + RuoYiConfig.getChartPath() + "/";
        //制动速度图
        String zhdImg = System.currentTimeMillis() + "-制动速度图.png";
        //svg转png
        if(StringUtils.isNotEmpty(dataTshjZhdResult.getZhdsdSvg())) {
            ProcessPictureUtils.convertToPng(dataTshjZhdResult.getZhdsdSvg(), rootPath + dataTshjZhdResult.getDataTaskId() + "/" + zhdImg);
            dataTshjZhdResult.setZhdsdImg("/profile/chartPath/" + dataTshjZhdResult.getDataTaskId() + "/" + zhdImg);
        }
        return dataTshjZhdResultMapper.insertDataTshjZhdResult(dataTshjZhdResult);
    }

    /**
     * 修改提升机-制动测试结果
     * 
     * @param dataTshjZhdResult 提升机-制动测试结果
     * @return 结果
     */
    @Override
    public int updateDataTshjZhdResult(DataTshjZhdResult dataTshjZhdResult)
    {
        dataTshjZhdResult.setUpdateTime(DateUtils.getNowDate());
        return dataTshjZhdResultMapper.updateDataTshjZhdResult(dataTshjZhdResult);
    }

    /**
     * 批量删除提升机-制动测试结果
     * 
     * @param zhdResultIds 需要删除的提升机-制动测试结果主键
     * @return 结果
     */
    @Override
    public int deleteDataTshjZhdResultByZhdResultIds(Long[] zhdResultIds)
    {
        return dataTshjZhdResultMapper.deleteDataTshjZhdResultByZhdResultIds(zhdResultIds);
    }

    /**
     * 删除提升机-制动测试结果信息
     * 
     * @param zhdResultId 提升机-制动测试结果主键
     * @return 结果
     */
    @Override
    public int deleteDataTshjZhdResultByZhdResultId(Long zhdResultId)
    {
        return dataTshjZhdResultMapper.deleteDataTshjZhdResultByZhdResultId(zhdResultId);
    }
}
